let a = 1;
console.log(a);

// var用来升级全局变量
var b = 2;
{
  var b = 3;
}
console.log(b);

// 数组解构
{
  let [a, b, c] = [1, 2, 3];
  let [[d, e], f] = [[4, 5], 6];
}

// 解构默认值
{
  let [foo = true] = []
}

// 对象解构
{
  let {foo, bar} = {foo: 'Hello', bar: 'World'}
}

// 圆括号的使用
let foo;
({foo} = {foo: 'hello'})

// 字符串解构
const [x, y, z] = 'yes'

// 扩展运算符
let arr1 = ['a', 'b']
let arr2 = [...arr1]

// rest运算符
function hellofn(first, ...arg) {
  for (let val of arg) {
    console.log(val)
  }
}
hellofn(1,2,3,4,5,6,7)

// 字符串模板
let hello = '你好'
let blog = `${hello}, 欢迎`
let blog2 = `<b>${hello}</b>,欢迎`
document.write(blog)
document.write(blog2)

// 运算支持
let an = 1;
let bn = 2;
let resn = `${an + bn}`;
document.write(`${an} + ${bn} = ${resn}`)

// 字符串查找
let target = "123"
let source = "343212334234342"
document.write(source.includes(target))
source.startsWith(target);
source.endsWith(target);
document.write(`<br />`)
document.write('jspang|'.repeat(3))

// 数字操作
let aa = '9.18'
console.log(Number.parseInt(aa))
console.log(Number.parseFloat(aa))

// Symbol
var g = Symbol('winni')
console.log(g)
console.log(g.toString())

// Symbol对象元素的保护作用
let obj = {name: 'winni', skill: 'blog'}
let age = Symbol()
obj[age] = 18
for(let key in obj) {
  console.log(obj[key])
}
console.log(obj)

// Proxy
var pro = new Proxy({
  add: function(val) {
    return val + 10;
  },
  name: 'I am winni'
}, {
  get: function(target, key, property) {
    console.log('come in Get')
    return target[key];
  },
  set: function(target, key, value, receiver) {
    console.log(`setting ${key} = ${value}`);
    return target[key] = value;
  }
})
console.log(pro.name)
pro.name="张三"
console.log(pro.name)

// class
class Coder {
  name (val) {
    console.log(val);
    return val;
  }
  skill(val) {
    console.log(this.name('winni') + ':Skill' + val);
  }
}
let my = new Coder;
my.name('winni2');
my.skill('web');